package module;

import core.AbstractCard;

/**
 * Utility class to load a .deck file, which consists of a list of tab-separated
 * (set, name) pairs, one per line.
 */
public class DeckLoader
{
	public static java.util.List<AbstractCard> loadDeck(String deckName) throws java.io.IOException
	{
		java.io.BufferedReader reader = new java.io.BufferedReader(new java.io.FileReader("decks/" + deckName + ".deck"));
		java.util.List<AbstractCard> deck = new java.util.LinkedList<AbstractCard>();
		String line;
		while ((line = reader.readLine()) != null) {
			java.util.StringTokenizer tokenizer = new java.util.StringTokenizer(line, "\t");
			deck.add(SetLoader.getAbstractCard(tokenizer.nextToken(), tokenizer.nextToken()));
		}
		return deck;
	}
}